-- fool
-- created by panyl
-- 愚者

return {
    apply = function(cardId)
        local args      = TarotM.query(cardId, "args") or {};
        local dbase     = TarotM.query(cardId, "dbase") or {};
        local condition = args["condition"];
        local bonus     = args["bonus"];
        
        if condition  then
            -- 附加傻子状态
            CombatStatusM.applyStatus(ME.user, "fool", condition);
            
            -- 需要刷新怪物属性
            local grids = {};
            for pos = 1, GRID_SIZE do
                local grid = DungeonM.getGridByPos(pos);
                if grid:isMonster() and not grid.monster:isDead() then
                    EventMgr.fire(event.MONSTER_INFO_UPDATED, {["pos"] = pos, });
                end
            end
            
            -- 抛事件
            EventMgr.fire(event.ADD_PROP, {["effect_id"] = dbase.effect_id, });
        end
        
        if type(bonus) == 'table' and #bonus > 0 then
            BonusM.doBonus(bonus, "tarot_bonus");
        end
    end,
};
